package com.xm.demo.exception;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@ControllerAdvice
public class ExceptionResolver {

    /*
    异常捕获统一处理，当前写入controller中，只能捕获当前controller产生的异常
     */
    @ExceptionHandler(value = {Exception.class})
    public void exceptionHandler(Exception e, HttpServletResponse response) throws IOException {
        response.getWriter().print("ExceptionResolver->"+e.getMessage());

    }
}
